// 时间格式化工具函数
export function formatPostTime(dateStr: string): string {
  const date = new Date(dateStr)
  const now = new Date()
  const diffMs = now.getTime() - date.getTime()
  const diffMin = Math.floor(diffMs / 60000)
  const diffHour = Math.floor(diffMs / 3600000)
  const diffDay = Math.floor(diffMs / 86400000)
  const diffMonth = Math.floor(diffDay / 30)
  const diffYear = Math.floor(diffMonth / 12)

  if (diffMin < 0) return '来自未来的更新';
  if (diffMin < 15) return '更新于刚刚';
  if (diffMin < 60) return '更新了有一会哦~';
  if (diffHour < 24) return `大约更新于${diffHour}小时前`;
  if (diffDay === 1) return '更新于昨天';
  if (diffDay === 2) return '更新于前天';
  if (diffDay === 3) return '更新于3天前';
  if (diffDay < 30) return `${diffDay}天前`;
  if (diffMonth < 12) return `${diffMonth}个月前`;
  if (diffYear === 1) return '一年前';
  if (diffYear === 2) return '两年前';
  return `${diffYear}年前`;
} 